package com.qq.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(description= "返回响应数据")
public class MyResponse {
    //error code : 0 :success ; non 0， error
    @ApiModelProperty(value = "响应编号")
    private int code = 0;    //returning message
    @ApiModelProperty(value = "响应信息")
    private String msg;
    @ApiModelProperty(value = "返回对象")
    private Object data;
    public MyResponse(WSErrorCode code){
        this(code.getCode() ,code.getMessage() ,null);
    }
    public MyResponse(int code , String msg){
        this(code ,msg ,null);
    }
    public MyResponse(int code , String msg , Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static MyResponse success(){
        return success(null);
    }

    public static MyResponse success(Object data){
        return new MyResponse(WSErrorCode.OP_SUCCESS.getCode(),WSErrorCode.OP_SUCCESS.getMessage(),data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
